//
//  BBMainViewController.m
//  BabyThermometer
//
//  Created by CaiLei on 10/2/14.
//  Copyright (c) 2014 baohu. All rights reserved.
//

#import "BBMainViewController.h"
#import "LeSideMenuViewController.h"

@interface BBMainViewController () <LeSideMenuVCDelegate>
@end

@implementation BBMainViewController {
    UIButton *_naviLeftBtn;
    id _observerSignIn;
    id _observerSignUp;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIButton *naviLeftBtn = [self leftNaviWithIconNamed:@"navi_side_icon"];
    UIButton *naviRightBtn = [self rightNaviWithIconNamed:@"navi_chart_icon"];
    self.vcTitle = @"12月28日 周二";
    
    [naviLeftBtn addTarget:self action:@selector(sideAction) forControlEvents:UIControlEventTouchUpInside];
    [naviRightBtn addTarget:self action:@selector(demoAction) forControlEvents:UIControlEventTouchUpInside];
    _naviLeftBtn = naviLeftBtn;
    self.sideMenuViewController.delegate = self;
    
    [[NSNotificationCenter defaultCenter] addObserverForName:Noti_SignIn object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
        if ([BBGlobalSingleton sharedInstance].gSignComeFrom == SignComeFrom_Settings) {
            [self.leSideMenuViewController dismissViewControllerAnimated:YES completion:nil];
            [self.leSideMenuViewController hideMenu];
        }
    }];

}

- (void)sideAction {
    [UIView animateWithDuration:0.35 animations:^{
        _naviLeftBtn.transform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI_2);
    }];
    [self.leSideMenuViewController showMenu];
}

- (void)demoAction {
}

- (void)leSideMenuVCDidHideMenu:(id)sender {
    [UIView animateWithDuration:0.35 animations:^{
        _naviLeftBtn.transform = CGAffineTransformRotate(_naviLeftBtn.transform, M_PI_2);
    }];
}

@end
